package com.tfnswebdesign.common {

// Holds step code from prev app
// main controller
  
  import flash.utils.Dictionary;
  
	public class Cache {
    
    /*-- variables --*/
    private var serverCache:Dictionary;
    
    /*-- constructor --*/
    public function Cache() {
      serverCache = new Dictionary();
    }
    
    
    /*-- checkCache --*/
    public function checkCache(identifier:String) {
      if (serverCache[identifier] != undefined) {
        return true;
      } else {
        return false;
      }
    }
    
    /*-- getCache --*/
    public function getCache(identifier:String) {
      if (checkCache(identifier)) {
        return serverCache[identifier];
      }
    }
    
    /*-- setCache --*/
    public function setCache(identifier:String, theData:*) {
      serverCache[identifier] = new Object();
      serverCache[identifier] = theData;
    }
    
    /*-- clearCache --*/
    public function clearCache(identifier:String = "") {
      if (identifier == "") {
        serverCache = new Dictionary();
      } else if (checkCache(identifier)) {
        serverCache[identifier] = undefined;
      }
    }
	
	}
}